﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using TRPOP.Common;
using TRPOP.CMS.Web.UI;


using TRPOP.CMS.Business;
using TRPOP.CMS.Model;
using System.Collections;

namespace TRPOP.CMS.Web.Admin
{
    public partial class FieldSetting : BaseAdmin
    {

        #region 当前页面权限验证
        protected override void SubPageInit()
        {
            base.m_SubPagePermission = Plugin.PermissionKeys.PermissionEnum.SystemManage_UploadFile;
        }
        #endregion

        #region 页面变量
        protected string m_Title = "附件删除设置";
        protected string m_strRefer = "FieldSetting.aspx";
        #endregion

        #region 页面事件

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadBase();
            }
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            AttachmentSettingInfo oAttachmentSettingInfo = SYSConfig.AttachmentSetting;

            oAttachmentSettingInfo.DelPageWhenDelNode = rbtdefaultdelpage.SelectedValue.ToBool();
            oAttachmentSettingInfo.DelImgWhenDelNode = rbtdefaultdelimg.SelectedValue.ToBool();
            oAttachmentSettingInfo.DelAttrWhenDelNode = rbtdefaultdelattr.SelectedValue.ToBool();
            oAttachmentSettingInfo.UpImageSize = txtUpImageSize.TextTrim.ToInt();
            oAttachmentSettingInfo.UpImageType = txtUpImageType.TextTrim;
            oAttachmentSettingInfo.PreserverAspectRatio = rbtblnPreserverAspectRatio.SelectedValue.ToBool();
            oAttachmentSettingInfo.ImgReSave = txtImgReSave.TextTrim;
            oAttachmentSettingInfo.UpImageMaxWidth = txtUpImageMaxWidth.TextTrim.ToInt();
            oAttachmentSettingInfo.UpAttachSize = txtUpAttachSize.TextTrim.ToInt();
            oAttachmentSettingInfo.UpAttachType = txtUpAttachType.TextTrim;

            SYSConfig.AttachmentSetting = oAttachmentSettingInfo;

            SubmitAlertAndThisNewLocation(true, m_strRefer);
        }

        #endregion

        #region 页面方法

        public void LoadBase()
        {
            AttachmentSettingInfo oAttachmentSettingInfo = SYSConfig.AttachmentSetting;

            rbtdefaultdelpage.SelectedValue = oAttachmentSettingInfo.DelPageWhenDelNode ? "1" : "0";
            rbtdefaultdelimg.SelectedValue = oAttachmentSettingInfo.DelImgWhenDelNode ? "1" : "0";
            rbtdefaultdelattr.SelectedValue = oAttachmentSettingInfo.DelAttrWhenDelNode ? "1" : "0";
            txtUpImageSize.Text = oAttachmentSettingInfo.UpImageSize.ToString();
            txtUpImageType.Text = oAttachmentSettingInfo.UpImageType.ToString();
            rbtblnPreserverAspectRatio.SelectedIndex = oAttachmentSettingInfo.PreserverAspectRatio ? 1 : 0;
            txtImgReSave.Text = oAttachmentSettingInfo.ImgReSave;
            txtUpImageMaxWidth.Text = oAttachmentSettingInfo.UpImageMaxWidth.ToString();
            txtUpAttachSize.Text = oAttachmentSettingInfo.UpAttachSize.ToString();
            txtUpAttachType.Text = oAttachmentSettingInfo.UpAttachType;
        }
        #endregion
    }
}
